/*
 * @Author: yansheng 610363806@qq.com
 * @Date: 2024-06-23 22:30:01
 * @LastEditors: zhang00001 774004514@qq.com
 * @LastEditTime: 2024-07-19 09:46:42
 * @FilePath: \cell-admin\vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import { envParse } from 'vite-plugin-env-parse'
import UnoCSS from 'unocss/vite'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'src')
        }
    },
    plugins: [
        vue(),
        envParse(),
        UnoCSS(),
        Components({
            resolvers: [
                AntDesignVueResolver({
                    importStyle: false // css in js
                })
            ]
        })
    ],
    server: {
        host: '0.0.0.0', // 监听所有IP
        warmup: {
            clientFiles: ['./*.html', './src/global.component.js']
        },
        proxy: {

            '/admin': {
                target: 'https://admin.cellsplus.top',
                // target: 'http://192.168.0.113:3000',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/admin/, '')
            }
        }


    },

    css: {
        preprocessorOptions: {
            less: {
                modifyVars: {
                    hack: `true; @import (reference) "${path.resolve('src/styles/variables.less')}";`
                },
                javascriptEnabled: true
            }
        }
    },
    esbuild: {
        drop: ['console', 'debugger']
    },
    build: {
        // 可不写，官方默认。
        minify: 'esbuild',
    },
})